//
//  MusicCD03Widget.swift
//  TimMusic
//
//  Created by nkl on 2024/10/17.
//

import Foundation
import SwiftUI

struct Small_MusicCD02_01: View {
    var model: ControlMusicModel
    var body: some View {
        ZStack {
            Color.yellow.ignoresSafeArea()
            if let data = model.imageData, let uiImage = UIImage(data: data) , !model.isStatic{
                Image(uiImage: uiImage).resizable().ignoresSafeArea()
            } else {
                Image("ic_small_placeholder").resizable().ignoresSafeArea()
            }
            VStack(alignment: .leading) {
                HStack {
                    Spacer()

                    if model.isPlay {
                        Image("ic_widget_pause")
                            .padding([.top, .trailing])
                            .modifier(AppClickModifier(urlString: "timMusic://musicControl?option=\(OptionType.pause.rawValue)", isStatic: model.isStatic))
                    } else {
                        Image("ic_widget_play")
                            .padding([.top, .trailing])
                            .modifier(AppClickModifier(urlString: "timMusic://musicControl?option=\(OptionType.play.rawValue)", isStatic: model.isStatic))
                    }
                }
                Spacer()
                Group {
                    TMText(title: model.title, font: 16, isBold: true, color: .white)
                    TMText(title: model.auth, font: 12, color: .white.opacity(0.6))
                        .padding([.top, .bottom], 12)

                }.padding(.horizontal)
            }
        }
    }
}

